class Solution {
public:
    int lengthOfLongestSubstring(string s) {
unordered_set<char> a;
int n=s.size();
int b=-1,shu=0;
for(int i=0;i<n;i++){
    if(i!=0){
        a.erase(s[i-1]);
    }
    while(b+1<n&&!a.count(s[b+1])){
        a.insert(s[b+1]);
        b++;
    }
    shu=max(shu,b-i+1);
}
return shu;
    }
};
